package javaMetaModel;

import java.util.ArrayList;
import java.util.List;
import javaMetaModel.type.MetaType;
import javaMetaModel.type.MetaTypeClasse;
import javaMetaModel.visitor.IMetaModelVisitor;

public class MetaClasse extends MetaClassifier {

	protected String mExtends = "";

	private final List<String> mImplements = new ArrayList<String>();

	protected final List<Attribute> mAttributes = new ArrayList<Attribute>();

	private final List<Methode> mMethods = new ArrayList<Methode>();

	public MetaClasse() {
		this("NewClasse");
	}

	public MetaClasse(String aName) {
		super(aName);
	}

	public String getExtends() {
		return mExtends;
	}

	public void setExtends(MetaClasse aClasse) {
		this.mExtends = aClasse.getCompleteName();
	}

	public void setExtends(String aClasse) {
		this.mExtends = aClasse;
	}

	public void addImplements(MetaInterface anInterface) {
		this.mImplements.add(anInterface.getCompleteName());
	}

	public void removeImplements(MetaInterface anInterface) {
		this.mImplements.remove(anInterface.getName());
	}

	public void addImplements(String anInterface) {
		this.mImplements.add(anInterface);
	}

	public void removeImplements(String anInterface) {
		this.mImplements.remove(anInterface);
	}

	public void removeAttribute(Variable aVariable) {
		this.mAttributes.remove(aVariable);
	}

	public void addMethod(Methode aMethode) {
		this.mMethods.add(aMethode);
	}

	public void removeMethode(Methode aMethode) {
		this.mMethods.remove(aMethode);
	}

	public void accept(IMetaModelVisitor aVisitor) {
		aVisitor.visitClasse(this);
	}

	public List<String> getImplements() {
		return mImplements;
	}

	public List<Methode> getMethods() {
		return mMethods;
	}

	public List<Attribute> getAttributes() {
		return mAttributes;
	}

	public void addAttribute(Attribute anAttribute) {
		this.mAttributes.add(anAttribute);
	}

	public void removeAttribute(Attribute anAttribute) {
		this.mAttributes.remove(anAttribute);
	}

	@Override
	public void setComment(String aComment) {
		this.mComments.setComment(aComment);
	}

	public void addAttribute(MetaType aType, String aName) {
		this.addAttribute(new Attribute(aType, aName));
	}

	public void addAttribute(MetaClasse aClasse, String aName) {
		this.addAttribute(new Attribute(new MetaTypeClasse(aClasse), aName));
	}

	public void addAttribute(MetaClasse aClasse, String aName,
			String aCardinality) {
		this.addAttribute(new Attribute(new MetaTypeClasse(aClasse), aName,
				aCardinality));
	}

}
